package dao.impl;
import java.util.ArrayList;

import dao.IDVDDao;
import entity.DVD;
import service.impl.DVDServiceImpl;

public class DVDDaoImpl implements IDVDDao{
	
	private ArrayList<DVD> manyDVD = new ArrayList<DVD>();
	
	public DVDDaoImpl(){
		manyDVD = new ArrayList<DVD>();
	}

	@Override
	public boolean save(DVD dvd) {
		if (manyDVD.contains(dvd)){
			return false;
		}
			manyDVD.add(dvd);
			return true;
	}

	@Override
	public boolean delete(String name) {
		if(manyDVD.contains(name)){
			manyDVD.remove(name);
			return true;
		}
			return false;
			
	}

	@Override
	public boolean update(DVD dvd) {
		return false;
	}

	@Override
	public ArrayList<DVD> selectByName(String name) {
		ArrayList<DVD> array = new ArrayList<DVD>();
		for(DVD dvd : manyDVD){
			if(dvd.getDvdName().equals(name)){
				array.add(dvd);
			}
		}
		return array;
	}

	@Override
	public ArrayList<DVD> selectByType(String type) {
		ArrayList<DVD> dvdType= new ArrayList<DVD>(); 
			for(DVD dvdType1 : manyDVD){
				if(dvdType1.getDvdType().equals(type)){
					manyDVD.add(type);
				}
						
			}
		return null;
	}

	@Override
	public ArrayList<DVD> selectAll() {
		return manyDVD;
	}

	@Override
	public boolean rentDVD(String name) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean returnDVD(String name) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public DVD[] selectAllNotRend() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public DVD[] descendingOrderByTime() {
		// TODO Auto-generated method stub
		return null;
	}

